home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / Kibitz / Chess.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  6.6 KB  |  183 lines  |  [TEXT/MPS ]

  1. #ifndef __CHESS__
  2. #define __CHESS__
  3.  
  4. #ifndef __TYPES__
  5. #include <types.h>
  6. #endif
  7.  
  8. #ifndef __APPLEEVENTS__
  9. #include <AppleEvents.h>
  10. #endif
  11.  
  12. #ifndef __PRINTING__
  13. #include <Printing.h>
  14. #endif
  15.  
  16.  
  17. #define WHITE 0
  18. #define BLACK 1
  19.  
  20. #define QSIDE 0
  21. #define KSIDE 1
  22.  
  23. #define EMPTY    0
  24. #define PAWN    1
  25. #define KNIGHT    2
  26. #define BISHOP    3
  27. #define ROOK    4
  28. #define QUEEN    5
  29. #define KING    6
  30.  
  31. #define BP PAWN            /* Black pawn    */
  32. #define BN KNIGHT        /* Black knight    */
  33. #define BB BISHOP        /* Black bishop    */
  34. #define BR ROOK            /* Black rook    */
  35. #define BQ QUEEN        /* Black queen    */
  36. #define BK KING            /* Black king    */
  37.  
  38. #define WP -PAWN        /* White pawn    */
  39. #define WN -KNIGHT        /* White knight    */
  40. #define WB -BISHOP        /* White bishop    */
  41. #define WR -ROOK        /* White rook    */
  42. #define WQ -QUEEN        /* White queen    */
  43. #define WK -KING        /* White king    */
  44.  
  45. #define OBNDS 32767        /* Out of bounds. */
  46.  
  47. #define START_IBNDS    21        /* Start of in-bounds for the board. */
  48. #define END_IBNDS    99        /* End of in-bounds for the board. */
  49.  
  50. #define BKPOS    25
  51. #define WKPOS    95
  52.  
  53. #define kGameContinues    0
  54. #define kYouWin            1
  55. #define kYouLose        2
  56. #define kStalemate        3
  57. #define kDrawBy50        4
  58. #define kDrawByRep        5
  59. #define kYouWinOnTime    6
  60. #define kYouLoseOnTime    7
  61. #define kWhiteResigns    8
  62. #define kBlackResigns    9
  63. #define kDrawGame        10
  64. #define kWhiteWins        11
  65. #define kBlackWins        12
  66. #define kDrawButtonText    13
  67.  
  68. #define kMessageDoc        -1
  69.  
  70. typedef struct {
  71.     short    kingLoc;
  72.     short    kingMoves;
  73.     short    rookMoves[2];
  74. } KingInfo;
  75.  
  76. typedef struct {
  77.     short    moveFrom;
  78.     short    moveTo;
  79.     long    value;
  80. } MoveElement;
  81. typedef MoveElement MoveListAry[];
  82. typedef MoveListAry *MoveListPtr, **MoveListHndl;
  83.  
  84. typedef struct {
  85.     short    moveFrom;
  86.     short    moveTo;
  87.     short    pieceCaptured;
  88.     short    pieceCapturedFrom;        /* For undoing en-passant. */
  89.     short    promoteTo;                /* For undoing promotions and recording games. */
  90. } GameElement;
  91. typedef GameElement GameListAry[];
  92. typedef GameListAry *GameListPtr, **GameListHndl;
  93.  
  94. typedef struct {
  95.     GameElement    move;
  96.     short        enPasMove;
  97.     short        enPasPawnLoc;
  98. } MoveRec;
  99.  
  100. typedef struct {
  101.  
  102.     short            version;            /* The file format version.                   */
  103.  
  104.     Boolean            printRecValid;        /* True if print record has been created.  */
  105.     TPrint            print;                /* Print record for file.                   */
  106.  
  107.     short            theBoard[120];        /* The current board position.               */
  108.     KingInfo        king[2];            /* King locations and castling info.       */
  109.     short            enPasMove;            /* Where an en-passant could occur.           */
  110.     short            enPasPawnLoc;        /* Location of en-passant-capture.           */
  111.     short            arngEnPasMove;        /* Initial arranged en-pas move.           */
  112.     short            arngEnPasPawnLoc;    /* Initial arranged en-pas capture.           */
  113.     short            numLegalMoves;        /* # of moves in legal move list.           */
  114.     short            gameIndex;            /* Index into game record.                   */
  115.     short            numGameMoves;        /* Size of game record.                       */
  116.     short            myColor;            /* True if I am playing black.               */
  117.     short            startColor;            /* True if black started game.               */
  118.     short            arrangeBoard;        /* True if in arrange-board mode.           */
  119.     short            palettePiece;        /* Piece hilited in arrange-board palette. */
  120.     unsigned long    defaultTime[2];        /* Default ticks for white/black.           */
  121.     unsigned long    timeLeft[2];        /* Ticks remaining for white/black.           */
  122.     Boolean            invertBoard;        /* True, display board inverted.           */
  123.     short            endFileInfo1;        /* Above info is saved to disk.               */
  124.  
  125.     Str32            reconnectZone;        /* Zone of opponent.                       */
  126.     Str32            reconnectMachine;    /* Machine of opponent.                       */
  127.     Str255            reconnectPath;        /* Full path of opponent's copy of Kibitz. */
  128.     Str32            reconnectApp;        /* Name of opponent's copy of Kibitz.       */
  129.     Boolean            justBoardWindow;    /* Just the board shows if true.           */
  130.     Boolean            docIsTemplate;        /* Doc opens as Untitled, file closed.       */
  131.     Boolean            keepCMWhite;        /* True if computer moves white pieces.    */
  132.     Boolean            keepCMBlack;        /* True if computer moves black pieces.    */
  133.     short            endFileInfo2;        /* Above info is saved to disk.               */
  134.                                         /* Above info saved in later version.       */
  135.  
  136.     Boolean            twoPlayer;            /* True if playing over the net.           */
  137.     long            gameID_0;            /* Used to match up incoming moves.           */
  138.     long            gameID_1;            /* Used to match up incoming moves.           */
  139.     short            sendReason;            /* Reason for sending the game.               */
  140.     short            drawBtnState;        /* State of the draw button.                */
  141.     AEAddressDesc    locOfOpponent;        /* AppleEvents address of opponent.           */
  142.     short            endSendInfo;        /* Above is send game info.                   */
  143.  
  144.     short            resync;                /* Non-zero if resync needed.               */
  145.     Boolean            creator;            /* True if this guy originated game.       */
  146.     unsigned long    displayTime[2];        /* Time shown (is <= timeLeft).               */
  147.     unsigned long    freezeTime[2];        /* Time left when clock stopped.           */
  148.     unsigned long    timerRefTick;        /* Reference tick for timer.               */
  149.     unsigned long    compMoveTick;        /* Tick when computer moved last.           */
  150.     unsigned long    gotUpdateTick;        /* Tick when we received new game info.       */
  151.     Boolean            compMovesWhite;        /* True if computer moves white pieces.    */
  152.     Boolean            compMovesBlack;        /* True if computer moves black pieces.    */
  153.     Str32            opponentName;        /* User name of opponent.                   */
  154.     Str32            opponentZone;        /* Zone of opponent.                       */
  155.     Str32            opponentMachine;    /* Machine of opponent.                       */
  156.     unsigned long    timeLastReceive;    /* Time that last move/message received.   */
  157.     short            endLocalInfo;        /* Above info is for one machine only.       */
  158.  
  159.     Boolean            configColorChange;    /* True if color change has been posted.   */
  160.     short            configColor;        /* Color change value to be applied.       */
  161.     Boolean            configTimeChange;    /* True if time change has been posted.       */
  162.     unsigned long    configTime[2];        /* Time change value to be applied.           */
  163.     short            endConfigInfo;        /* Above info is config setting which will */
  164.                                         /* not be applied until a NULL event.       */
  165.  
  166.     MoveListHndl    legalMoves;            /* Handle of legal moves.                   */
  167.     GameListHndl    gameMoves;            /* Handle of game record (saved to disk).  */
  168.     TEHandle        message[2];            /* Handles to in/out messages.               */
  169.     Handle            sound;                /* Handle to recorded sound.               */
  170.     ControlHandle    sendMessage;        /* Handle to send button.                   */
  171.     ControlHandle    beepOnMove;            /* Handle to move-beep checkbox.           */
  172.     ControlHandle    beepOnMssg;            /* Handle to mssg-beep checkbox.           */
  173.     ControlHandle    gameSlider;            /* Handle to slider custom control.           */
  174.     ControlHandle    wbStart[2];            /* Handles to arrange board controls.       */
  175.     ControlHandle    resign;                /* Handle to resign button.                   */
  176.     ControlHandle    draw;                /* Handle to draw button.                   */
  177.     ControlHandle    record;                /* Handle to record sound button.           */
  178.     ControlHandle    sendSnd;            /* Handle to send sound button.               */
  179.     short            endControls;        /* Above info is reference to controls.       */
  180.  
  181. } TheDoc, *TheDocPtr, **TheDocHndl;
  182.  
  183. #endif __CHESS__